<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>

<body>
    <script>
        // onload代表页面所有结构(包含DOM，样式，动画，flash)加载完毕以后再去执行js代码
        window.onload = function() {
            var btn = document.querySelector('button');
            console.log(btn);

            btn.onclick = function() {
                alert(666)
            }
        }
    </script>
    <button>点击</button>

</body>

</html>